package com.rocket.bedroom.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rocket.bedroom.dao.BlockDao;
import com.rocket.bedroom.pojo.BlockEntity;
import com.rocket.bedroom.service.IBlockService;
import com.sun.deploy.security.BlockedDialog;
import jdk.nashorn.internal.ir.Block;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

/**
 * @Author: 周毅
 * @ClassName:
 * @Description: TODO
 * @Date: Create in 20:56 2020/5/3
 * @ModifyBy:
 */
@Service
public class BlockServiceImpl extends ServiceImpl<BlockDao, BlockEntity> implements IBlockService {

    @Override
    public Integer hasBlockName(String blockName) {
        Assert.notNull(blockName, "判断BlockName是否重复 BLOCK_NAME IS NULL");
        LambdaQueryWrapper<BlockEntity> lambdaQuery = Wrappers.lambdaQuery();
        lambdaQuery.eq(BlockEntity::getBlockName, blockName);
        return super.count(lambdaQuery);
    }
}
